//auto gen by paipai.java.augogen ver 3.0.0
//author skyzhuang
//source idl: com.icson.deal.idl.ModifyShoppingcartAo.java


#ifndef ICSON_DEAL_SHOPPINGCART_BO_CPRODUCTERROR_BY_AUTOGEN_V5_H
#define ICSON_DEAL_SHOPPINGCART_BO_CPRODUCTERROR_BY_AUTOGEN_V5_H


#include "app_platform/intf_serializable.h"
#include <string>
#include <sstream>
#include <iostream>


namespace icson
{
namespace deal
{
namespace shoppingcart
{
namespace bo
{


class CProductError : public ISerializable
{
	public:
		std::string m_sLastErrMsg;///<错误信息

		/**
		 * 添加商品错误的错误码
		 *
		 * 版本 >= 0
		 */
		uint32_t dwErrorCode;

		/**
		 * 版本 >= 0
		 */
		uint8_t cErrorCode_u;

		/**
		 * 添加商品错误的错误信息
		 *
		 * 版本 >= 0
		 */
		std::string strErrorMessage;

		/**
		 * 版本 >= 0
		 */
		uint8_t cErrorMessage_u;




	public:
		CProductError():
		dwErrorCode(0),
		cErrorCode_u(0),
		cErrorMessage_u(0) {}
				CProductError& operator = (const CProductError& obj){

			this->dwErrorCode = obj.dwErrorCode;
			this->cErrorCode_u = obj.cErrorCode_u;
			this->strErrorMessage = obj.strErrorMessage;
			this->cErrorMessage_u = obj.cErrorMessage_u;
			return *this;
		}

	public:


		/**
		 * 是否设置添加商品错误的错误码了
		 * 
		 * @param uint32_t:dwErrorCode
		 *  
		 * 
		 */
		 bool  IsErrorCodeSet() const{
				 return  cErrorCode_u != 0;
		}


		/**
		 * 获取uflag添加商品错误的错误码了
		 * 
		 * @param uint32_t:dwErrorCode
		 *  
		 * 
		 */
		 const uint8_t   GetErrorCodeUFlag() const{
				 return  cErrorCode_u;
		}


		/**
		 * 设置添加商品错误的错误码
		 * 
		 * @param uint32_t:dwErrorCode
		 *  
		 * 
		 */
		 void  SetErrorCode( const uint32_t& sVal, uint8_t cUFlag=1){
				dwErrorCode = sVal;
				cErrorCode_u = cUFlag;
		}


		/**
		 * 获取添加商品错误的错误码
		 * 
		 * @return dwErrorCode value 类型为:uint32_t
		 * 
		 */
		 const uint32_t&  GetErrorCode() const {
				return dwErrorCode;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cErrorCode_u
		 *  
		 * 
		 */
		 void  SetErrorCode_u( const uint8_t& sVal){
				cErrorCode_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cErrorCode_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetErrorCode_u() const {
				return cErrorCode_u;
		}


		/**
		 * 是否设置添加商品错误的错误信息了
		 * 
		 * @param std::string:strErrorMessage
		 *  
		 * 
		 */
		 bool  IsErrorMessageSet() const{
				 return  cErrorMessage_u != 0;
		}


		/**
		 * 获取uflag添加商品错误的错误信息了
		 * 
		 * @param std::string:strErrorMessage
		 *  
		 * 
		 */
		 const uint8_t   GetErrorMessageUFlag() const{
				 return  cErrorMessage_u;
		}


		/**
		 * 设置添加商品错误的错误信息
		 * 
		 * @param std::string:strErrorMessage
		 *  
		 * 
		 */
		 void  SetErrorMessage( const std::string& sVal, uint8_t cUFlag=1){
				strErrorMessage = sVal;
				cErrorMessage_u = cUFlag;
		}


		/**
		 * 获取添加商品错误的错误信息
		 * 
		 * @return strErrorMessage value 类型为:std::string
		 * 
		 */
		 const std::string&  GetErrorMessage() const {
				return strErrorMessage;
		}


		/**
		 * 获取添加商品错误的错误信息
		 * 
		 * @return strErrorMessage value 类型为:std::string
		 * 
		 */
		 std::string&  GetErrorMessage() {
				return strErrorMessage;
		}


		/**
		 * 设置
		 * 
		 * 此字段的版本 >= 1
		 * @param uint8_t:cErrorMessage_u
		 *  
		 * 
		 */
		 void  SetErrorMessage_u( const uint8_t& sVal){
				cErrorMessage_u = sVal;
		}


		/**
		 * 获取
		 * 
		 * @return cErrorMessage_u value 类型为:uint8_t
		 * 
		 */
		 const uint8_t&  GetErrorMessage_u() const {
				return cErrorMessage_u;
		}

		virtual bool Serialize(CByteStreamNetwork& bs){
		
			uint32_t dwMyLen = 0;
			if(bs.isStoring()) //for write in buffer
			{
				//can not larger than 1 M.
				CByteStreamNetwork bsDummy(NULL, 1024 * 1024, false);
				//bsDummy for precheck the xo size...
				bsDummy.isStoring(true);
				Serialize_i(bsDummy);
				dwMyLen = bsDummy.getWrittenLength();
				bs & dwMyLen;
				Serialize_i(bs);
			}
			else
			{    //for read from buffer
				bs & dwMyLen;
				uint32_t dwReadedLen = bs.getReadLength();
				Serialize_i(bs);
				dwReadedLen = bs.getReadLength() - dwReadedLen;
				// dwReadedLen for the size of xo
				if( dwReadedLen > dwMyLen ){
					return false;
				}
				//go through the unwanted mem position...
				bs.goForward( dwMyLen - dwReadedLen );
			}

			return bs.isGood();
		}

		bool Serialize_i(CByteStreamNetwork& bsTmp){

			bsTmp & dwErrorCode; // 序列化添加商品错误的错误码 类型为uint32_t
			bsTmp & cErrorCode_u; // 序列化 类型为uint8_t
			bsTmp & strErrorMessage; // 序列化添加商品错误的错误信息 类型为String
			bsTmp & cErrorMessage_u; // 序列化 类型为uint8_t
			return bsTmp.isGood();
		}

		const char* GetLastErrMsg() const{
			return m_sLastErrMsg.c_str();
		}

		bool VerifyProductError(){

			if(!IsErrorCodeSet()){
				m_sLastErrMsg = "Miss Param:errorCode";
				return false;
			}

			if(!IsErrorMessageSet()){
				m_sLastErrMsg = "Miss Param:errorMessage";
				return false;
			}
			return true;
		}

		void DumpData(std::ostream& oss) const{
		
			oss<<"[dwErrorCode:"<<dwErrorCode<<"] ";
			oss<<"[cErrorCode_u:"<<(int)cErrorCode_u<<"] ";
			oss<<"[strErrorMessage:"<<strErrorMessage<<"] ";
			oss<<"[cErrorMessage_u:"<<(int)cErrorMessage_u<<"] ";
		
		}

		// codydeng提供,非常好的dump方法 ^-^  。。。。。
		template<typename T>
		T & DumpPlusData(T& oss){
			oss<<"dwErrorCode:"<<dwErrorCode;
			oss<<"cErrorCode_u:"<<cErrorCode_u;
			oss<<"strErrorMessage:"<<strErrorMessage;
			oss<<"cErrorMessage_u:"<<cErrorMessage_u;
			return oss;
		}

		// wileywang提供,树形dump方法 ^-^  。。。。。
		void DumpDataTree(std::ostream& os, int ident = 0)const {
			g_pprint(os, "dwErrorCode", dwErrorCode, ident);
			g_pprint(os, "cErrorCode_u", cErrorCode_u, ident);
			g_pprint(os, "strErrorMessage", strErrorMessage, ident);
			g_pprint(os, "cErrorMessage_u", cErrorMessage_u, ident);
		}
		
		//提供ToString借口，默认为DumpData格式，请按需要进行修改
		std::string ToString() const{
			std::stringstream ss;
			DumpData(ss);
			return ss.str();
		}

/**
 ********************以下信息是每个版本的字段********************
 */

};

}
}
}
}

#endif /* ICSON_DEAL_SHOPPINGCART_BO_CPRODUCTERROR_BY_AUTOGEN_V5_H */
